var Relation = require('../relation');
var User = require('../user')
var Card = require('../card')
var Activity = require('../activity');
var initRedisCache = require('../../lib/InitRedisCache');
var Faction = require('../faction');
var fmproxy = require('../factionmember');
var Creditspolicy = require('../creditspolicy');
var FactionMember = require('../../entity').FactionMember;
var activity = require('../../entity').Activity;
var UserE = require('../../entity').User;
var CardE = require('../../entity').Card;

function test(){
    var factionId = '54102f517c99781e517c7d96';
    FactionMember.find({faction: factionId}).exec(function(err, fms){
        for(var i in fms){
            (function(fm){
                if(fm.member.id){
                    if(typeof fm.member.id === 'object'){
                        FactionMember.update({_id: fm._id}, {$set: {'member.id': fm.member.id.toHexString()}}, {}, function(err, data){
                            if(err) return console.log(err);
                            console.log(data);
                        })
                    }
                }
            })(fms[i])
        }
    })
}

test();
